package org.example.fancystudy.CompletableFuture;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author chaigq
 * @version 1.0
 * @date 2022/5/19 20:40
 */
public class Math {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() ->{
            return "Hello";
        });
        System.out.println(completableFuture.get());
    }

    public synchronized void functions(){
        CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() ->{
            return "Hello";
        });
        System.out.println(completableFuture.join());
    }

    ReentrantLock reentrantLock = new ReentrantLock();

    public void function (){
        reentrantLock.lock();
        try{

        }catch (Exception e){

        }finally {
            reentrantLock.unlock();
        }
    }

}
class MyThread implements Runnable{

    @Override
    public void run() {

    }
}

class MyCallThread implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println("========com========");
        return "CallableThread CallBack";
    }
}
